//o clasa Lista care sa implementeze operatiile de mai sus,pe langa alte operatii specifice: 
//va avea o operatie de inserare a unui element la o pozitie specificata.

public class Lista implements Structura{
        private int [] elemente;
        public void adauga (int e){
                elemente[elemente.length+1] = e;
        }
        public void inserare (int e, int location){
                int bufferLength = (elemente.length - location)+1;
                int [] buffer = new int [bufferLength];
                for (int i=location; i<elemente.length; i++)
                        for (int j=0; j<bufferLength; j++)
                        buffer[j] = elemente[i];
                elemente[location] = e;
                for (int i=(location+1); i<elemente.length; i++)
                        for (int j=0; j<bufferLength; j++)
                                elemente[i] = buffer[j];
        }
        public void sterge (int e){
            int [] buffer = new int[0];
            for (int i=0; i<elemente.length-1; i++)
                     buffer[i] = elemente[i];
            elemente = buffer;
    }
        public Lista(int [] elements){
                this.elemente = elements;
        }
}

